import graph.Graph;
import graph.GraphKind;
import linkedGraph.LinkedGraph;
import linkedGraph.Vertex;
import seqGraph.MatrixGraph;

public class Main {

    public static void main(String[] args) throws Exception {
        Graph graph;
        // 顶点的值
        String[] datas = {"V0", "V1", "V2", "V3", "V4", "V5"};
        // 顶点之间的邻接关系
        int[][] arcs = {
                {0, 7, 1, 5, 0, 0},
                {7, 0, 6, 0, 3, 0},
                {1, 6, 0, 7, 6, 4},
                {5, 0, 7, 0, 0, 2},
                {0, 3, 6, 0, 0, 7},
                {0, 0, 4, 2, 7, 0},
        };

        // 邻接矩阵
        graph = new MatrixGraph(GraphKind.DG, 10, datas, arcs);
        graph.showArcs();

        graph.traverseDFS(3);
        graph.traverseDFS(4);
        graph.traverseBFS(3);
        graph.traverseBFS(4);

        // 邻接表
        // 初始化顶点集合
        Vertex<String>[] vertexs = new Vertex[datas.length];
        for (int i = 0; i < vertexs.length; i++) {
            vertexs[i] = new Vertex<>(datas[i], null);
        }

        // 创建邻接表
        graph = new LinkedGraph(GraphKind.DG, 10, vertexs, arcs);
        graph.showArcs();

        graph.traverseDFS(3);
        graph.traverseDFS(4);
        graph.traverseBFS(3);
        graph.traverseBFS(4);
    }

}
